#coding=utf-8
'''
Created on 2013-10-30

@author: Ben

控制台服务端 用于输出信息
'''

import socket

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('localhost', 10000))
server.listen(1)
connection, address = server.accept()
while True:
    try:
        buf = connection.recv(1200)
        if len(buf) == 0:
            break
        print len(buf)
        print buf
    except:
        print 'socket error'